package com.dhl.springbootrabbitmq.listening;

import com.dhl.springbootrabbitmq.config.TtlQueueConfig;

import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;

/**
 * rabbit监听器
 * @author danghailiang
 */
@Slf4j
@Component
public class RabbitListening {
    /**
     * 监听对列
     * @param message
     * @param channel
     */
    @RabbitListener( queues = TtlQueueConfig.QD_DEAD_QUEUE)
    public void receiveD(Message message, Channel channel){
        log.info("交换机：{},接收到的数据是：{}",TtlQueueConfig.QD_DEAD_QUEUE,new String(message.getBody(), StandardCharsets.UTF_8));
    }
}
